/*
 * @Description:
 * @Author: jun.wu
 * @Date: 2022-09-21 14:17:01
 * @LastEditors: jun.wu
 * @LastEditTime: 2022-12-06 14:04:11
 */
import Vue from "vue";
import "normalize.css/normalize.css"; // A modern alternative to CSS resets

import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import locale from "element-ui/lib/locale/lang/en"; // lang i18n
import "@/styles/index.scss"; // global css
import checkPermission from "@/mixin/checkPermission";

import App from "./App";
import store from "./store";
import router from "./router";
import components from "@/components";

import "@/icons"; // icon
import "@/permission"; // permission control

import * as directives from "@/directives"; // directives
import * as filters from "@/filters";
import i18n from "@/lang";

Object.keys(directives).forEach((key) => {
  Vue.directive(key, directives[key]); //注册自定义指令
});

Object.keys(filters).forEach((key) => {
  Vue.filter(key, filters[key]); //注册自定义的过滤器
});
// set ElementUI lang to EN
// Vue.use(ElementUI, { locale });
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)
Vue.use(ElementUI, {
  // 此时i18n会根据当前的locale属性去找当前的显示内容
  i18n: (key, value) => i18n.t(key), //t方法会去对应的语言包里寻找对应的语言
  //改变locale的值就可以改变语言包
});

Vue.use(components); //注册自己的组件

//全局混入检查对象
Vue.mixin(checkPermission); //所有组件都有检查的方法

Vue.config.productionTip = false;

new Vue({
  el: "#app",
  router,
  store,
  i18n,
  render: (h) => h(App),
});
